app.controller('reportController',['$scope',"weeklyReportService", function ($scope,weeklyReportService) {
	weeklyReportService.getInformation().then(function(informationData){
	  $scope.reports=informationData;
  })
  /*
	 * weeklyReportService.getSummaryDesignation().then(function(summaryDesignationData){
	 * $scope.demands = [];
	 * Object.keys(summaryDesignationData).forEach(function(key) { var demand =
	 * new Object(); demand.name = key; demand.innerMap =
	 * summaryDesignationData[key];
	 * Object.keys(demand.innerMap).forEach(function(key) { demand.count=key;
	 * demand.remark=(demand.innerMap)[key]; });
	 * 
	 * $scope.demands.push(demand); }); }),
	 * weeklyReportService.getSummaryCapability().then(function(summaryCapabilityData){
	 * $scope.groups = [];
	 * Object.keys(summaryCapabilityData).forEach(function(key) { var group =
	 * new Object(); group.name = key; group.count = summaryCapabilityData[key];
	 * 
	 * $scope.groups.push(group); }); })
	 */
  
  jQuery(function($) {
		$(document).ready(function() {
			$.ajax({
				type : "GET",
				url : "./api/reports/getSummaryDesignationReport",
				data : "{}",
				success : function(Result) {
					var date = [];
					date=Result;
					DreawChartColumn(date);
				},
				error : function(Result) {
					alert("Error");
				}
			});
			
			$.ajax({
				type : "GET",
				url : "./api/reports/getSummaryCapabilityReportPie",
				data : "{}",
				success : function(Result) {
					DreawChartPie(Result);
				},
				error : function(Result) {
					alert("Error");
				}
			});
			$.ajax({
				type : "GET",
				url : "./api/reports/getSummaryLocationReportPie",
				data : "{}",
				success : function(Result) {
					DreawLocationPie(Result);
				},
				error : function(Result) {
					alert("Error");
				}
			});
			$(".zhedie").click(function(){
				var dis=$("#kindschart").css("display");
				
				if(dis==="none"){
					$("#kindschart").css('display','block');
					$(".zhedie").attr("value","Hide The Charts");
				}else{
					$("#kindschart").css('display','none');
					$(".zhedie").attr("value","Show The Charts");
				}
				
			});
			
		});
		
			
		
		function DreawChartColumn(dates) {

			$('#containercolumn')
					.highcharts(
							{

								chart: {
							        type: 'column'
							    },
								title : {
									text : 'Bench Summary'
								},
								subtitle : {
									text : 'By Desigation'
								},
								xAxis : {
									categories : [ 
									               'Senior Director', 
									               'Director',
									               'Portfolio Manager', 
													'Senior Manager',
													'Manager', 
													'Senior Consultant',
													'Consultant', 
													'Associate Consultant',
													'Senior Software Engineer',
													'Software Engineer',
													'Software Associate', 
													'Sub-Con'

									],
									crosshair : true
								},
								yAxis: {
							        min: 0,
							        title: {
							            text: 'Number'
							        }
							    },
							    plotOptions: {
							        column: {
							            pointPadding: 0.2,
							            borderWidth: 0
							        }
							    },
							    credits: { enabled: false },
								series : [ {
									name : 'Bench Number',
									data : dates
								} ]
							});
		}
		
		function DreawChartPie(dates) {

			$('#containerpie')
					.highcharts(
							{

								chart: {
						            plotBackgroundColor: null,
						            plotBorderWidth: null,
						            plotShadow: false,
						            type: 'pie'
						        },
								title : {
									text : 'Bench Summary'
								},
								subtitle : {
									text : 'By Capability'
								},
								tooltip: {
						            pointFormat: 'Num:<b>{point.y}  </b>{series.name}:<b>{point.percentage:.1f}% </b>'
						        },
							    plotOptions: {
							    	pie: {
						                allowPointSelect: true,
						                cursor: 'pointer',
						                dataLabels: {
						                    enabled: false
						                },
						                showInLegend: true
						            }
							    },
							    credits: { enabled: false },
								series : [ {
									name : 'Percentage',
									colorByPoint: true,
									data :dates
								
								} ]
							});
		}
		
		function DreawLocationPie(dates) {

			$('#locationpie')
					.highcharts(
							{

								chart: {
						            plotBackgroundColor: null,
						            plotBorderWidth: null,
						            plotShadow: false,
						            type: 'pie'
						        },
								title : {
									text : 'Bench Summary'
								},
								subtitle : {
									text : 'By Location'
								},
								tooltip: {
						            pointFormat: 'Num:<b>{point.y}  </b>{series.name}:<b>{point.percentage:.1f}% </b>'
						        },
							    plotOptions: {
							    	pie: {
						                allowPointSelect: true,
						                cursor: 'pointer',
						                dataLabels: {
						                    enabled: false
						                },
						                showInLegend: true
						            }
							    },
							    credits: { enabled: false },
								series : [ {
									name : 'Percentage',
									colorByPoint: true,
									data :dates
								
								} ]
							});
		}
	});

  

}]);
